package com.github.freegeese.maven.plugin.autocode.demo.base;

import java.util.ArrayList;
import java.util.List;

/**
 * 分页实现
 */
public class PageImpl implements Pageable {
    // 页码
    private Integer pageNumber;
    // 页面大小
    private Integer pageSize;
    // 总页数
    private Integer totalPages;
    // 总记录数
    private Long totalRecords;
    // 页面数据
    private List<?> content = new ArrayList<>();

    public PageImpl() {
    }

    public PageImpl(Integer pageNumber, Integer pageSize) {
        this.pageNumber = pageNumber;
        this.pageSize = pageSize;
    }

    @Override
    public Integer getPageNumber() {
        return pageNumber;
    }

    public void setPageNumber(Integer pageNumber) {
        this.pageNumber = pageNumber;
    }

    @Override
    public Integer getPageSize() {
        return pageSize;
    }

    @Override
    public Integer getOffset() {
        return getPageNumber() * getPageSize();
    }

    @Override
    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    @Override
    public Long getTotalRecords() {
        return totalRecords;
    }

    public void setTotalRecords(Long totalRecords) {
        this.totalRecords = totalRecords;
    }

    @Override
    public List<?> getContent() {
        return content;
    }

    public void setContent(List<?> content) {
        this.content = content;
    }
}
